package menu

import (
	"context"
	"jinrigaoping/api/platform/internal/svc"
	"jinrigaoping/api/platform/internal/types"

	"jinrigaoping/rpc/sys/sys"

	"github.com/zeromicro/go-zero/core/logx"
)

type MenuAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewMenuAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MenuAddLogic {
	return &MenuAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *MenuAddLogic) MenuAdd(req *types.SysMenuAddReq) (resp *types.SysMenuAddRes, err error) {

	if _, err := l.svcCtx.SysRpc.SysMenuAdd(l.ctx, &sys.SysMenuAddReq{
		ParentId:    req.ParentId,
		Name:        req.Name,
		Component:   req.Component,
		IsLink:      req.IsLink,
		MenuSort:    req.MenuSort,
		Path:        req.Path,
		Redirect:    req.Redirect,
		Title:       req.Title,
		Icon:        req.Icon,
		IsHide:      req.IsHide,
		IsKeepAlive: req.IsKeepAlive,
		IsAffix:     req.IsAffix,
		LinkUrl:     req.LinkUrl,
		MenuType:    req.MenuType,
		IsIframe:    req.IsIframe,
	}); err != nil {
		return nil, err
	}
	return &types.SysMenuAddRes{}, nil
}
